<?php
/*
 * @Author: 杨红兵 
 * @Date: 2022-09-05 15:22:45 
 * @Last Modified by: 杨红兵
 * @Last Modified time: 2022-09-05 15:24:20
 */

namespace app\libraries\utils\lock;

interface LockInterface
{
    /**
     * 加锁
     *
     * @Author YangHB
     * @DateTime 2022-09-05 15:03:35
     *
     * @param string $key 加锁 Key 名
     * @param integer $time 锁定时间
     * @param string $lockValue 重入锁
     *
     * @return string|bool 返回加锁标识
     */
    public function lock(string $key, int $time, string $lockValue);

    /**
     * 加锁，需要等待
     *
     * @Author YangHB
     * @DateTime 2022-09-05 15:53:19
     *
     * @param string $key
     * @param integer $time
     * @param string $lockValue
     * @param integer $timeOut
     * @return string|bool
     */
    public function lockWait(string $key, int $time, string $lockValue, int $timeOut);

    /**
     * 释放锁
     *
     * @Author YangHB
     * @DateTime 2022-09-05 15:04:27
     *
     * @param string $key
     * @param string $lockValue
     *
     * @return boolean
     */
    public function unLock(string $key, string $lockValue): bool;
}
